package com.sdcx.agrobank;

import android.content.Intent;
import android.graphics.Color;
import android.os.CountDownTimer;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;

import androidx.fragment.app.Fragment;

import com.blankj.utilcode.util.ToastUtils;
import com.sdcx.agrobank.adapter.FragmentAdapter;
import com.sdcx.agrobank.base.BaseActivity;

import com.sdcx.agrobank.ui.activity.Main2Activity;
import com.sdcx.agrobank.util.CustomViewPager;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Handler;

import butterknife.BindView;

public class MainActivity extends BaseActivity {

   /* @BindView(R.id.customVP)
    CustomViewPager customVP;
    @BindView(R.id.radio_main)
    RadioButton radioMain;
    @BindView(R.id.radio_video)
    RadioButton radioVideo;
    @BindView(R.id.radio_activity)
    RadioButton radioActivity;
    @BindView(R.id.radio_my)
    RadioButton radioMy;
    @BindView(R.id.radio_group)
    RadioGroup radioGroup;*/
    @BindView(R.id.rlLinearLayout)
    RelativeLayout rlLinearLayout;
    private static boolean mBackKeyPressed = false;
    private CountDownTimer timer;

    @Override
    protected int initLayout() {
        return R.layout.activity_main;
    }

    @Override
    protected void init() {
      //  状态栏沉浸
        statusBarImmersionBar();

    }

    @Override
    protected void initDate() {
/*        customVP.setOffscreenPageLimit(3);
        List<Fragment> arrayList = new ArrayList<>();
       // arrayList.add(new FragmentMain());
       // arrayList.add(new FragmentVideo());
       // arrayList.add(new FragmentActivity());
       // arrayList.add(new FragmentMy());
        FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), arrayList);
        //设置适配器
        customVP.setAdapter(adapter);*/
        getButtonJudge();

        timer = new CountDownTimer(3000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
            }

            @Override
            public void onFinish() {
                startActivity(new Intent(MainActivity.this, Main2Activity.class));
                finish();
            }
        }.start();
    }

    @Override
    protected void initLogic() {
       /* radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.radio_main:
                        getButtonJudge();
                        customVP.setCurrentItem(0);
                        break;
                    case R.id.radio_video:
                        getButtonJudge();
                        customVP.setCurrentItem(1);
                        break;
                    case R.id.radio_activity:
                        getButtonJudge();
                        customVP.setCurrentItem(2);
                        break;
                    case R.id.radio_my:
                        getButtonJudge();
                        customVP.setCurrentItem(3);
                        break;
                }
            }
        });*/
    }
    /*返回键逻辑*/
    @Override
    public void onBackPressed() {
        if (!mBackKeyPressed) {
            ToastUtils.showShort("再按一次退出程序");
            mBackKeyPressed = true;
            new Timer().schedule(new TimerTask() {//延时两秒，如果超出则擦错第一次按键记录
                @Override
                public void run() {
                    mBackKeyPressed = false;
                }
            }, 2000);
        } else {//退出程序
            this.finish();
        }
    }
    @Override
    protected void getOnDestroy() {

    }
    //切换字体图标
    private void getButtonJudge() {
        /*if (radioMain.isChecked()) {
            radioMain.setTextColor(Color.argb(255,191,102,40));
        } else {
            radioMain.setTextColor(Color.argb(178,191,102,40));
        }
        if (radioVideo.isChecked()) {
            radioVideo.setTextColor(Color.argb(255,191,102,40));
        } else {
            radioVideo.setTextColor(Color.argb(178,191,102,40));
        }
        if (radioActivity.isChecked()) {
            radioActivity.setTextColor(Color.argb(255,191,102,40));
        } else {
            radioActivity.setTextColor(Color.argb(178,191,102,40));
        }
        if (radioMy.isChecked()) {
            radioMy.setTextColor(Color.argb(255,191,102,40));
        } else {
            radioMy.setTextColor(Color.argb(178,191,102,40));
        }*/
    }

    @Override
    protected void onDestroy() {
        if (timer!=null){
            timer.cancel();
        }
        super.onDestroy();

    }
}
